package com.game.gui {
	import com.game.data.Data;
	import flash.display.BitmapData;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	public class DrawMap extends BitmapData {
		private var step:int = 0;
		public function DrawMap(tileStep:int, level:Array, initTile:Point, finTile:Point) {
			super(Data.getInstance().stageWidth, Data.getInstance().stageHeight, false, 0x0);
			step = tileStep;
			this.copyPixels(Data.getInstance().mapTexture, this.rect, new Point());
			drawGradient();
		}
		private function drawGradient():void {
			var tmp:BitmapData = new BitmapData(Data.getInstance().stageWidth, 20, true, 0);
			for (var k:int = 0; k < 20; k++) {
				tmp.fillRect(new Rectangle(0, k, Data.getInstance().stageWidth, 1), RGBToHex((k / 20) * 255, 0, 0, 0));
			}
			this.copyPixels(tmp, tmp.rect, new Point(0, Data.getInstance().myLevel.length * step - 20));
		}
		private function RGBToHex(a:uint, r:uint, g:uint, b:uint):uint {
			var hex:uint = (a << 24 | r << 16 | g << 8 | b);
			return hex;
		}
	}
}